package io;

import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.Scanner;

public class Test3 {
    public static void main(String[] args) throws FileNotFoundException {
        FileOutputStream fos=new FileOutputStream("abc.txt");
        OutputStreamWriter osw=new OutputStreamWriter(fos, StandardCharsets.UTF_8);
        BufferedWriter bw=new BufferedWriter(osw);
        PrintWriter pw=new PrintWriter(bw, true);
        Scanner scan= new Scanner(System.in);
        System.out.println("请输入内容");
        while (true){
            String scan1 = scan.next();
            if ("exit".equalsIgnoreCase(scan1)){
                break;
            }else {
                pw.println(scan1);
            }
        }
        System.out.println("写入完毕");
        pw.close();
    }
}
